import yaml
import os

'''print(yaml.load("""
 - Hesperiidae
 - Papilionidae
 - Apatelodidae
 - Epiplemidae
 """, Loader=yaml.FullLoader))
#结果：['Hesperiidae', 'Papilionidae', 'Apatelodidae', 'Epiplemidae']

print(yaml.load(open('yaml.txt'), Loader=yaml.FullLoader))
#通过文件的形式读取，yaml文件中对格式的要求比较高，空格输入必须对齐等'''

print(yaml.dump({'b': [11, 22]}))
#结果：
# b:
#- 11
#- 22
if not os.path.exists('yamldump.txt'):
    with open('yamldump.txt','w') as f:
        yaml.dump({'b': [11, 22]},stream=f)